﻿@{
    ViewData["Title"] = "OrgManager";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="~/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="~/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="~/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="~/css/animate.min.css" rel="stylesheet" />
    <link href="~/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .dSearch .btn {
            margin-top: 10px;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .modal-body .input-group-addon {
            width: 105px;
        }

        .modal-body .input-group {
            margin-bottom: 10px;
            width: 100%;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }
    </style>
}
    <form id="form1" runat="server">
        <div id="dMain">
            <div class="wrapper wrapper-content animated fadeInRight">
                <div class="ibox" style="margin-bottom: 0px;">
                    <div class="ibox-title">
                        <h5>
                            <asp:Label ID="lblDMName" runat="server" Text=""></asp:Label>&nbsp;部门管理
                        </h5>
                        <div class="ibox-tools">
                            <a class="btn btn-primary btn-circle btn-outline" title="返回" href="@Url.Action("index","Department",new { aera="System"})" style="margin-top: -7px;"><i class=" fa fa-mail-reply"></i></a>
                            <a class="btn btn-primary btn-circle btn-outline" title="刷新" href="javascript:location.href=location.href;" style="margin-top: -7px;"><i class=" fa fa-refresh"></i></a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div id="toolbar" class="dSearch">
                            <button class="btn btn-primary btn-sm" type="button" onclick="showPage('添加组织机构','@Url.Action("OrgEdit","Department",new { aera="System"})&DMID=@ViewBag.DMID',500,510,true)">添加信息</button>
                        </div>
                        <table id="tabData" class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>名称</th>
                                    <th>代码</th>
                                    <th>拼音码</th>
                                    <th>属性</th>
                                    <th>备注</th>
                                    <th>停用</th>
                                    <th>索引</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <input id="hfLogInfo" type="hidden" value="删除了一条数据" />
        <input id="hfModular" type="hidden" value="组织机构" />
        @*<input id="hfPageUrl" type="hidden" value="<%=Request.Url.PathAndQuery %>" />*@
        <input id="hfPageUrl" type="hidden" value="@ViewBag.reurl" />
        @*<div id="dJson" style="display: none;"><%=GetJsonData() %></div>*@
    </form>
    @section scripts{
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
    <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>

    <script src="/js/My97DatePicker/WdatePicker.js"></script>




        <script type="text/javascript">
            $(function () {
                var tabHeight = document.documentElement.clientHeight - 100;
                $('#tabData').bootstrapTable({
                    height: tabHeight,
                    //data: $("#dJson").text() != "" ? JSON.parse($("#dJson").text()) : "",
                    url: "GetDepartmentJsonData?DMID=@ViewBag.DMID",
                    dataType: "json",
                    columns: [
                        { align: 'center', width: "50px", checkbox: true },
                        { field: 'OrgName', align: 'center', width: "150px" },
                        { field: 'OrgNo', align: 'center', width: "70px" },
                        { field: 'PinYinNo', align: 'center', width: "70px" },
                        { field: 'NewOrgDepartment', align: 'center', width: "100px" },
                        { field: 'Remark', align: 'center' },
                        {
                            align: 'center', width: "70px", formatter: function (value, row, index) {
                                return ["<i class=\"ihand fa fa-" + (row.State == "1" ? "check-square-o" : "square-o") + " text-success\" onclick=\"ChangeState('" + row.ID + "','" + row.State + "')\"></i>"]
                            }
                        },
                        { field: 'Flag1', align: 'center', width: "60px", sortable: true },
                        { align: 'center', width: "100px", formatter: operateFormatter }
                    ],
                    toolbar: '#toolbar',//工具按钮用哪个容器
                    buttonsClass: "sm btn-white",//按钮class
                    pageSize: 100,//分页条数
                    clickToSelect: true,//设置true将在点击行时，自动选择单选或复选框
                    singleSelect: true,//为true则禁止多选
                    cache: false,//是否缓存
                    cookie: true,//是否启用cookie
                    cookieIdTable: "OrgManager",//cookie键值
                    pagination: true,//是否分页
                    showColumns: true,//是否显示所有的列
                    showRefresh: true,//是否显示刷新按钮
                    search: true,//是否启用搜索
                    showPaginationSwitch: true,//是否显示分页切换按钮
                    showExport: true,//是否启用导出
                    striped: false,//是否显示行间隔色
                    onSearch: function (text) {
                        if (text != "") {
                            $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                                var str = "<span class=\"bg-yellow\">" + text + "</span>";
                                var NewText = $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).text().replaceAll(text, str);
                                $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html(NewText);
                            })
                        }
                    }
                });
            })
            function ChangeState(_ID,  _ParVal) {
                $.ajax({
                    type: "post",
                    url: "ChangeState",
                    dataType: "json",
                    async: false,
                    data: {  ID: _ID, ParVal: _ParVal },
                    success: function (msg) {
                        if (msg > 0) {
                            location.href = location.href;
                        }
                    }
                });
            }
            function DelData(_ID) {
                $.ajax({
                    type: "post",
                    url: "DelDepartment",
                    dataType: "json",
                    async: false,
                    data: { ID: _ID },
                    success: function (msg) {
                        if (msg > 0) {
                            location.href = location.href;
                        }
                    }
                });
            }
            function operateFormatter(value, row, index) {
                return [
                    "<a title=\"修改\" class=\"text-success\" href=\"javascript:;\" onclick=\"showPage('修改组织机构信息','@Url.Action("OrgEdit", "Department",new { aera="System"})&DMID=@ViewBag.DMID&ID=" + row.ID + "',500,510,true)\">编辑</a>&emsp;" +
                    "<a title=\"删除\" class=\"text-danger\" href=\"javascript:;\" onclick=\"_Confirm('确定要删除这条数据？',function(){ DelData('" + row.ID + "') })\">删除</a>"
                ];
            }
        </script>

    }
